﻿using Grpc.Core;
using SX.BaseService.Service;
using SX.Core;
using SX.Core.Auth;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace GrpcBase
{
    public class QueryPermissionService: GetPermissions.GetPermissionsBase
    {
        private readonly ISysUserService _userService;

        public QueryPermissionService(ISysUserService sysUserService,ILoginInfo loginInfo)
        {         
            _userService = sysUserService;
        }
        public override async Task<GetPermissionsReply> GetPermissionsByUId(GetPermissionsRequest request, ServerCallContext context)
        {
            var list=await _userService.QueryPermissionList(request.Userid);
            GetPermissionsReply reply = new GetPermissionsReply();
            reply.Permissions = JsonHelper.SerializeObject(list);
            return reply;
        }
    }
}
